package com.etone.web.controller.system;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.etone.common.annotation.Log;
import com.etone.common.core.controller.BaseController;
import com.etone.common.core.domain.AjaxResult;
import com.etone.common.enums.BusinessType;
import com.etone.system.domain.SysStorage;
import com.etone.system.service.ISysStorageService;
import com.etone.common.utils.poi.ExcelUtil;
import com.etone.common.core.page.TableDataInfo;

/**
 * 货位Controller
 * 
 * @author etone
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/system/storage")
public class SysStorageController extends BaseController
{
    @Autowired
    private ISysStorageService sysStorageService;

    /**
     * 查询货位列表
     */
    @PreAuthorize("@ss.hasPermi('system:storage:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysStorage sysStorage)
    {
        startPage();
        List<Map<String,Object>> list = sysStorageService.selectSysStorageList(sysStorage);
        return getDataTable(list);
    }



    /**
     * 获取货位详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:storage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysStorageService.selectSysStorageById(id));
    }

    /**
     * 新增货位
     */
    @PreAuthorize("@ss.hasPermi('system:storage:add')")
    @Log(title = "货位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStorage sysStorage)
    {
        return toAjax(sysStorageService.insertSysStorage(sysStorage));
    }

    /**
     * 修改货位
     */
    @PreAuthorize("@ss.hasPermi('system:storage:edit')")
    @Log(title = "货位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStorage sysStorage)
    {
        return toAjax(sysStorageService.updateSysStorage(sysStorage));
    }

    /**
     * 删除货位
     */
    @PreAuthorize("@ss.hasPermi('system:storage:remove')")
    @Log(title = "货位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysStorageService.deleteSysStorageByIds(ids));
    }
}
